<?php
// tests/PostTest.php
class PostTest extends PHPUnit_Framework_TestCase {
	private $CI;

	public function setUp() {
		$this->CI = &get_instance();
	}

	public function testGetAllPosts() {
		$this->CI->load->model('post');
		$posts = $this->CI->post->getAll();
		$db = $this->CI->load->database('test', true);
		$db->CI->db->query("CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);");
		
// 		$this->CI->load->dbforge();
// 		$this->CI->dbforge->create_table('asd');
// 		$fields = array(
// 				'id' => array('type' => 'TEXT'),
// 				'name' => array('type' => 'TEXT')
// 		);
// 		$this->dbforge->add_column('Persons', $fields);
		
		$sql = "INSERT INTO Persons (LastName, FirstName)
        VALUES (".$this->CI->db->escape("Sosa").", ".$this->CI->db->escape("Maximiliano").")";
		
		$this->CI->db->query($sql);
		
// 		$query = $this->CI->db->query("select * from Persons");	
// 		if ($query->num_rows() > 0)
// 		{
// 			foreach ($query->result() as $row)
// 			{
// 				echo $row->title;
// 				echo $row->name;
// 				echo $row->body;
// 			}
// 		}
		$this->CI->db->close();
		$this->assertEquals(5, count($posts));
	}
}
?>